<?php

/**
 * 商品咨询
 */

namespace app\shop\common;

class FaqCommon extends \app\base\common\SiteCommon {


    protected function index() {

        $id = request('get', 'id', 0, 'intval');
        $app = request('get', 'app', '', 'html_clear');
        if(empty($id) || empty($app)){
            $this->error404();
        }

        $info = target($app . '/' . $app)->getInfo($id);
        if(empty($info) || !$info['status']) {
            $this->error404();
        }

        $info['url'] = url($app . '/info/index', ['id' => $id]);

        $this->setMeta('商品咨询 - ' . $info['title']);
        $this->pageInfo['name'] = '商品咨询';
        $this->setCrumb([
            [
                'name' => $info['title'],
                'url' => $info['url']
            ],
            [
                'name' => '商品咨询',
                'url' => URL
            ]
        ]);
        $info['images'] = unserialize($info['images']);


        $urlParam = [];
        $urlParam['id'] = $id;
        $urlParam['app'] = $app;
        $where = [];
        $where['app'] = $app;
        $where['has_id'] = $id;
        $pageLimit = 20;

        $model = target('shop/ShopFaq');
        $count = $model->countList($where);
        $pageData = $this->pageData($count, $pageLimit, $urlParam);
        $list = $model->loadList($where, $pageData['limit'], 'time desc');

        $this->assign('pageList', $list);
        $this->assign('page', $pageData['html']);
        $this->assign('info', $info);
        $this->siteDisplay('shop_faq');
    }


}